//
//  DownloadMVTableViewCell.m
//  Gegeda_music_MY
//
//  Created by lanou3g on 15/11/7.
//  Copyright © 2015年 周莹. All rights reserved.
//

#import "DownloadMVTableViewCell.h"
#import "MVModel.h"
#import "UIImageView+WebCache.h"

@implementation DownloadMVTableViewCell

//当nib被唤醒时调用
- (void)awakeFromNib {
    self.headerImageView.layer.cornerRadius = 10;
    self.headerImageView.clipsToBounds = YES;
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

#pragma mark - cell赋值
-(void)setCellDataWithModel:(MVModel *)model{
    [self.headerImageView sd_setImageWithURL:[NSURL URLWithString:model.mv_cover]];
    self.songLabel.text = model.title;
    self.singerLabel.text = model.artist_name;
    self.progessView.progress = model.progressValue;
    self.progressLabel.text = [NSString stringWithFormat:@"%.0f%%", model.progressValue * 100];
    //判断
    if (model.isDownFinished) {
        self.palseAndPlayButton.userInteractionEnabled = NO;
    } else {
        self.palseAndPlayButton.userInteractionEnabled = YES;
    }
}
#pragma mark - 更新下载进度
-(void)updateDownLoadProgress:(MVModel *)model{
    self.progressLabel.text = [NSString stringWithFormat:@"%.0f%%", model.progressValue * 100];
    self.progessView.progress = model.progressValue;
}
#pragma mark - 播放或者暂停按钮被点击
- (IBAction)palseAndPlayButtonDidClicked:(id)sender {
    if (self.palseAndPlayButton.isSelected) {
        [self.palseAndPlayButton setImage:[UIImage imageNamed:@"36.png"] forState:UIControlStateNormal];
    } else {
        [self.palseAndPlayButton setImage:[UIImage imageNamed:@"37.png"] forState:UIControlStateNormal];
    }
    self.palseAndPlayButton.selected = ! self.palseAndPlayButton.selected;
    if (self.delegate && [self.delegate respondsToSelector:@selector(DownloadMVTableViewCellpalseAndPlayButtonDidClicked:withIsPlay:)]) {
        [self.delegate DownloadMVTableViewCellpalseAndPlayButtonDidClicked:self withIsPlay:self.palseAndPlayButton.selected];
    };
    
    
}



@end
